"use strict";

var create = { track: {}}; //define the namespace

(function () {
    var connection = $.connection('/echo'), map = null;

    this.start = function (leafletMap) {
        this.map = leafletMap;

        connection.start(function () {
            console.log("connection started!");
        });
        connection.received(function (data) {
            
            var polyline = L.polyline(latlngs, { color: 'red' }).addTo(map);
        });
        track.send();
        track.add(12);
    };

    this.stop = function() {
        connection.stop();
    };
}).apply(create.track); //apply to namespace


//(http://router.project-osrm.org/viaroute?loc=51.500,0.100&loc=51.500,0.1001
//decode route_geometry to list of point. https://github.com/DennisSchiefer/Project-OSRM-Web/blob/master/WebContent/routing/OSRM.RoutingGeometry.js
//use leaflet to draw the route